<template>
  <div>
    <h4>页面正在跳转...</h4>
  </div>
</template>

<script>
export default {
  methods: {
    init() {
      let url = window.location.href;
      let params = url.substring(url.indexOf("?") + 1, url.indexOf("#"));
      if (params == "#/qiyewx?") {
        params = url.substring(url.indexOf("?") + 1);
      }
      console.log("params -> " + params);
      if (params.indexOf("state") != -1 || params.indexOf("auth_code") != -1) {
        // 请求后台校验
          this.$store
            .dispatch("user/qiyeWechat", params).then(res => {
            console.log("ret ->" + JSON.stringify(res));
            this.$router.push({
              path: this.redirect || "/"
            });
          })
          .catch(err => {
            this.$message.error(err.msg);
            this.$router.replace("/login");
          });
      }
    }
  },
  created() {
    this.init();
  }
};
</script>